<!--预览文件-->
<template>
  <div id="popupbody" v-if="dialogVisible">
    <div class="popupbody-box" ref="dialogBox">
      <div class="popupbody-title">
        <span>预览文件</span>
        <span class="el-icon-close" @click="closePOpup"></span>
      </div>
      <div class="popupbody-boxin" style="padding:10px;">
        <div class="weekclass-body" ref="pdf">
          <iframe frameborder=0 name="showHere" scrolling=auto :src="iframeSrcLine" class="iframeBoxLine"></iframe>
          <!--          <iframe class="iframeBoxLine" src="https://view.officeapps.live.com/op/embed.aspx?src=http%3A%2F%2Fdoctext%2Elayoxx%2Ecom%3A80%2Fuploads%2Foffice%2F20220323%2F20220323150451%2Edocx&amp;wdPrint=1&amp;wdStartOn=1&amp;wdEmbedCode=0" frameborder="0"></iframe>-->
        </div>
      </div>
      <div class="popupbody-footer">
        <el-button size="small" @click="closePOpup">返回</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'studentMultiple',
  props: ['visible', 'iframeSrc'],
  data() {
    return {
      dialogVisible: this.visible,
      iframeSrcLine: '',
      tableHeight: 100
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        console.log('数据清理选中:', this.dynamicTagsArray)
        let n = this;
        this.$nextTick(() => {
          let height = n.$refs.dialogBox.offsetHeight;  //top 50 1 search 50 page 50 10 footer 50 1
          this.tableHeight = height - (65 + 56 + 20)
        })
        this.getHttpFn()
      } else {
        this.iframeSrcLine = ''
      }
    }
  },
  created() {
  },
  methods: {
    async getHttpFn() {
      let data = await this.$fetch(this.api.system_setting, this.searchForm)
      if (!data.code) {
        // 'xlsx','xls',
        if(this.iframeSrc.indexOf('.xlsx')!==-1 || this.iframeSrc.indexOf('.xls')!==-1){
          let data_ = `wdDownloadButton=false&wdPrint=1&amp;wdStartOn=1&wdEmbedCode=0&src=${data.vo.url + this.iframeSrc}`
          this.iframeSrcLine = `https://view.officeapps.live.com/op/embed.aspx?${data_}`;
        }else{
          let data_ = `${data.vo.url + this.iframeSrc}`
          // this.iframeSrcLine = `https://view.officeapps.live.com/op/view.aspx?${data_}`;
          this.iframeSrcLine = `http://view.xdocin.com/xdoc?_xdoc=${data_}`;
        }
      }
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
.popupbody-boxin {
  min-width: 750px;
}

.weekclass-body {
  height: 550px;
  overflow: hidden;
}

/*48 40 24*/
.iframeBoxLine {
  width: 100%;
  /*height: 674px;*/
  /*margin-top: -98px;*/
}
</style>
